#include <cstdio>

double money[1005];
double total, average, balance1, balance2, cent;
int N, M;

void input() {
    for(int i = 0; i < N; ++i) {
        scanf("%lf", &money[i]);
    }
}

double cal() {
    total = 0.0;
    for(int i = 0; i < N; ++i) {
        total += money[i];
    }
    average = total / N;
    average = (int)(average * 100) / 100.0;
    balance1 = balance2 = 0.0;
    M = 0;
    for(int i = 0; i < N; ++i) {
        if(money[i] < average) {
            balance1 += average - money[i];
        }
        if(money[i] > average) {
            balance2 += money[i] - average;
            ++M;
        }
    }
    cent = balance2 - balance1;
    if(cent - 0.01 * M > 1e-9) {
        cent -= 0.01 * M;
    } else {
        cent = 0.0;
    }
    return balance1 + cent;
}

void output() {
    printf("$%.2f\n", cal());
}

int main() {
    while(~scanf("%d", &N) && N > 0) {
        input();
        output();
    }
    return 0;
}
